<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="css/book.css"/>
    <title>入家酒店</title>
</head>
<body>

<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand">入家酒店</a>
    <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav">
            <li class="nav-item active">
                <a class="nav-link" href="#">预订 <span class="sr-only">(current)</span></a>
            </li>
        </ul>
    </div>
</nav>

<div>
    <table class="table">
        <thead>
        <tr>
            <th scope="col">房间类型</th>
            <th scope="col">价格</th>
        </tr>
        </thead>
        <tbody>

        </tbody>
    </table>
</div>

<div class="w-100 fixed-bottom bg-light" style="height: 12%;">
    <div class="card">
        <div class="card-body">
            <form action="query.action" method="post">
                <div class="justify-content-around d-flex">
                    <div>
                        入住时间：
                        <input id="in_info" type="date" name="checkin">
                    </div>
                    <div>
                        退房时间：
                        <input id="out_info" type="date" name="checkout">
                    </div>
                    <input type="submit" value="查询">
                </div>
            </form>
        </div>
    </div>
</div>

<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
<script src="js/bootstrap.js"></script>

<script>
    $(function () {
        var date_now = new Date();
        var year = date_now.getFullYear();
        var month = date_now.getMonth()+1<10?"0"+(date_now.getMonth()+1):(date_now.getMonth()+1);
        var date = date_now.getDate() <10?"0"+date_now.getDate():date_now.getDate();
        $("#in_info").attr("value", year+"-"+month+"-"+date);
        $("#in_info").attr("min", year+"-"+month+"-"+date);

        date_now.setTime(date_now.getTime()+24*60*60*1000);
        year = date_now.getFullYear();
        month = date_now.getMonth()+1<10?"0"+(date_now.getMonth()+1):(date_now.getMonth()+1);
        date = date_now.getDate() <10?"0"+date_now.getDate():date_now.getDate();
        $("#out_info").attr("value", year+"-"+month+"-"+date);
        $("#out_info").attr("min", year+"-"+month+"-"+date);
    })

    var in_info = document.getElementById('in_info');
    in_info.onblur = function(){
        debugger
        var date_now = new Date($("#in_info").val());
        date_now.setTime(date_now.getTime()+24*60*60*1000);
        var year = date_now.getFullYear();
        var month = date_now.getMonth()+1<10?"0"+(date_now.getMonth()+1):(date_now.getMonth()+1);
        var date = date_now.getDate() <10?"0"+date_now.getDate():date_now.getDate();
        $("#out_info").attr("value", year+"-"+month+"-"+date);
        $("#out_info").attr("min", year+"-"+month+"-"+date);
    };

    var out_info = document.getElementById('out_info');
    out_info.onblur = function(){
        debugger
        var date_now = new Date($("#out_info").val());
        date_now.setTime(date_now.getTime()-24*60*60*1000);
        var year = date_now.getFullYear();
        var month = date_now.getMonth()+1<10?"0"+(date_now.getMonth()+1):(date_now.getMonth()+1);
        var date = date_now.getDate() <10?"0"+date_now.getDate():date_now.getDate();
        $("#in_info").attr("value", year+"-"+month+"-"+date);
        $("#in_info").attr("max", year+"-"+month+"-"+date);
    };
</script>
</body>
</html>
